//C:ex9_2.cpp:9.9:static.cpp --using a static local variable
#include <iostream>
#include <string>
// constants
const int ArSize = 20;
// function prototype
//void strcount(const char *str);
void strcount(const std::string str);
int main(void)
{
    using namespace std;
    //char intput[ArSize];
    //char next;
    string input;
    cout << "Enter a line:\n";
    getline(cin, input);
    while (input.length() != 0)
    {   
        // if (input.length() == 0)
        //     break;
        strcount(input);
        cout << "Enter next line (empty line to quit):\n";
        getline(cin, input);
    }
    cout << "Bye\n";
    return 0;
}

//void strcount(const char *str)
void strcount(const std::string str)
{
    using namespace std;
    static int total = 0;    // static local variable
    int count = 0;           // automatic local variable

    cout << "\"" << str << "\" contains ";
    count = str.length();
    total += count;
    cout << count << " characters\n";
    cout << total << " characters total\n";
}